﻿<UserControl xmlns:ParseControls="clr-namespace:ParseControls;assembly=ParseControls"  x:Class="ParseOnlineAdmin.ParseAppsConfigView"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:local="clr-namespace:ParseOnlineAdmin"
			 Background="#ff777777" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="500">

	<UserControl.Resources>

		<local:ParseObjectToStringConverter x:Key="valueConverter" />

		<SolidColorBrush x:Key="transp" Color="Transparent"  Opacity="0" />
		<SolidColorBrush x:Key="snow" Color="Transparent" Opacity="0.0001" />
		<SolidColorBrush  x:Key="light"  Color="White" Opacity="0.35" />
		<SolidColorBrush x:Key="over" Color="White"  Opacity="0.50" />
		<SolidColorBrush x:Key="selected"  Color="White"  Opacity="0.75" />

		<LinearGradientBrush x:Key="_redBrush" StartPoint="0,0" EndPoint="0,1">
			<GradientStop Color="#AC1417" Offset="0.0" />
			<!--<GradientStop Color="Transparent" Offset="0.4" />
		<GradientStop Color="Transparent" Offset="0.5" />
		<GradientStop Color="Transparent" Offset="0.6" />-->
			<GradientStop Color="#E32224" Offset="1" />
		</LinearGradientBrush>
		
		<!-- FocusVisual -->
		<Style x:Key="SimpleFocusVisual">
			<Setter Property="Control.Template">
				<Setter.Value>
					<ControlTemplate>
						<Border
						BorderBrush="Transparent"
						BorderThickness="0"
						SnapsToDevicePixels="true">
							<!--
							<Border.Effect>
							<DropShadowEffect ShadowDepth="0"
							Color="Gray"
							BlurRadius="5" />
							</Border.Effect>
						-->
						</Border>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="listboxitem" TargetType="ListBoxItem">
			<Setter Property="Opacity" Value="0" />
			<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
			<Setter Property="RenderTransform">
				<Setter.Value>
					<TranslateTransform Y="-10" />
				</Setter.Value>
			</Setter>
			<Setter
			Property="FocusVisualStyle"
			Value="{StaticResource SimpleFocusVisual}" />
			<Setter Property="BorderBrush" Value="#fff" />
			<Setter Property="BorderThickness" Value="0,0,0,1" />
			<Setter Property="Foreground" Value="#fff" />
			<Setter Property="Background" Value="{StaticResource light}" />
			<Setter Property="HorizontalContentAlignment" Value="Stretch" />
			<Setter Property="HorizontalAlignment" Value="Stretch" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ListBoxItem">
						<Grid Background="{TemplateBinding Background}"
						SnapsToDevicePixels="true">
			
							<Border x:Name="line" Background="{TemplateBinding Background}"
							        BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
							    SnapsToDevicePixels="true" />

							<ContentPresenter Margin="0" HorizontalAlignment="Stretch"
							Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"
							SnapsToDevicePixels="true" />
						</Grid>
						<ControlTemplate.Triggers>
							<EventTrigger RoutedEvent="Loaded">
								<BeginStoryboard>
									<Storyboard Storyboard.DesiredFrameRate="30">
										<DoubleAnimation AccelerationRatio="0.3" DecelerationRatio="0.7"
										Duration="0:0:0.7" From="0"
										Storyboard.TargetProperty="Opacity" To="1" />
										<DoubleAnimation AccelerationRatio="0.3" DecelerationRatio="0.7"
										Duration="0:0:0.7" From="-10"
										Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)"
										To="0" />
									</Storyboard>
								</BeginStoryboard>
							</EventTrigger>
							<Trigger Property="IsSelected" Value="True">
								<Setter Property="Background" TargetName="line" Value="{StaticResource _redBrush}" />
								<Setter Property="TextBlock.Foreground" Value="#fff" />
							</Trigger>
							<!--<MultiTrigger>
								<MultiTrigger.Conditions>
									<Condition Property="IsSelected" Value="False" />
									<Condition Property="IsMouseOver" Value="True" />
								</MultiTrigger.Conditions>
								<Setter Property="Opacity" TargetName="line" Value="1" />
								<Setter Property="BorderThickness" TargetName="line" Value="0,0,0,1" />
								<Setter Property="BorderBrush" TargetName="line" Value="#007ACC" />
								<Setter Property="Cursor" Value="Hand" />
								<Setter Property="Fill" TargetName="rectBg" Value="#fff" />
								<Setter Property="Opacity" TargetName="rectBg" Value="0.5" />
							</MultiTrigger>
							<MultiTrigger>
								<MultiTrigger.Conditions>
									<Condition Property="IsSelected" Value="True" />
									<Condition Property="IsMouseOver" Value="True" />
								</MultiTrigger.Conditions>
								<Setter Property="Opacity" TargetName="line" Value="1" />
							</MultiTrigger>-->
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
			<Style.Triggers>
				<Trigger Property="IsEnabled" Value="false">
					<Setter Property="Background" Value="Silver" />
					<Setter Property="Foreground" Value="White" />
				</Trigger>
			</Style.Triggers>
		</Style>
		<Style x:Key="listbox" TargetType="{x:Type ListBox}">
			<Setter  Property="BorderThickness"  Value="0" />
			<Setter  Property="Margin"  Value="0" />
			<Setter  Property="Padding"  Value="0" />
			<Setter Property="Background"  Value="{StaticResource snow}" />
		</Style>
		<Style x:Key="textbox" TargetType="{x:Type TextBox}">
			<Setter Property="Background" Value="{StaticResource light}" />
			<Setter Property="BorderThickness" Value="0" />
			<Setter Property="Padding" Value="3" />
			<Style.Triggers>
				<Trigger Property="IsMouseOver" Value="true">
					<Setter Property="Background" Value="{StaticResource over}" />
					<Setter  Property="BorderThickness"  Value="0" />
				</Trigger>
				<Trigger  Property="IsFocused" Value="true">
					<Setter  Property="Background" Value="{StaticResource selected}" />
					<Setter  Property="BorderThickness" Value="0" />
				</Trigger>
			</Style.Triggers>
		</Style>
	</UserControl.Resources>
	
	<Grid Margin="8,8,8,0">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="2*"/>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="2*"/>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="2*"/>
			<ColumnDefinition Width="Auto"/>
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>
		
		<Border Grid.ColumnSpan="7" Grid.Row="0" />
		
		<TextBlock Text="Name" FontWeight="Bold" Foreground="#fff" VerticalAlignment="Center" 
				   Margin="5,3" Grid.Column="0" Grid.Row="0" />
		<ParseControls:FwTextBox x:Name="txtName" Text="" Margin="3" Grid.Column="1" Grid.Row="0" />

		<TextBlock Text="Key" FontWeight="Bold" Foreground="#fff" VerticalAlignment="Center" 
				   Margin="5,3" Grid.Column="2" Grid.Row="0" />
		<ParseControls:FwTextBox x:Name="txtKey" Text="" Margin="3" Grid.Column="3" Grid.Row="0" />

		<TextBlock Text=".NET" FontWeight="Bold" Foreground="#fff" VerticalAlignment="Center" 
				   Margin="5,3" Grid.Column="4" Grid.Row="0" />
		<ParseControls:FwTextBox x:Name="txtSecret" Text="" Margin="3" Grid.Column="5" Grid.Row="0" />

		<ParseControls:FwButton 
			Margin="3" Grid.Column="6" Grid.Row="0" 
			Height="30" Width="30"
			Click="Button_Click"  >
			<ParseControls:FwButton.Content>
				<Viewbox>
					<Canvas x:Name="appbar_add" Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0" Margin="-20">
						<Path Width="38" Height="38" Canvas.Left="19" Canvas.Top="19" Stretch="Fill" 
							  Fill="#FFffffff" Data="F1 M 35,19L 41,19L 41,35L 57,35L 57,41L 41,41L 41,57L 35,57L 35,41L 19,41L 19,35L 35,35L 35,19 Z "/>
					</Canvas>
				</Viewbox>
			</ParseControls:FwButton.Content>    
		</ParseControls:FwButton>

		<ListBox Grid.Row="1" Grid.ColumnSpan="7" Margin="3"
				   ItemContainerStyle="{StaticResource listboxitem}"
					 Style="{StaticResource listbox}"
						ItemsSource="{Binding Path=AppItems, Mode=TwoWay,
							UpdateSourceTrigger=PropertyChanged}"
								ScrollViewer.HorizontalScrollBarVisibility="Hidden"
									ScrollViewer.VerticalScrollBarVisibility="Auto"
									SelectedItem="{Binding Path=SelectedApp, Mode=TwoWay,
										UpdateSourceTrigger=PropertyChanged}">

			<ListBox.ItemTemplate>
				<DataTemplate>
					<Grid  Margin="2">
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
						</Grid.RowDefinitions>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*" />
							<ColumnDefinition Width="Auto" />
							<ColumnDefinition Width="Auto" />
						</Grid.ColumnDefinitions>

						<TextBlock Grid.Column="0" Grid.Row="0"
							   Margin="3,1"  FontWeight="Bold" 
							   Text="{Binding Path=Name,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

						<TextBlock Grid.Column="1" Grid.Row="0"
							   Margin="3,1"  FontWeight="Bold" 
							   Text="{Binding Path=Key,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

						<TextBlock Grid.Column="2" Grid.Row="0" Margin="15,1,0,1"
							   FontWeight="Bold" 
							   Text="{Binding Path=Secret,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
						
						<!--<TextBlock   Grid.Column="1"   Grid.Row="0"
							   Margin="3,1"  Foreground="#777"  TextAlignment="Right"
													Text="{Binding Path=ClassName}"
													TextTrimming="CharacterEllipsis" />-->

					</Grid>
				</DataTemplate>
			</ListBox.ItemTemplate>

		</ListBox>

		<Border Grid.ColumnSpan="7" Grid.Row="2" />
		<ParseControls:FwButton Content="OK" Margin="3" Grid.Column="6" Grid.Row="2" 
                                Click="Button_Click_1"  />
        <ParseControls:FwButton x:Name="btnDeleteApp" Margin="3" Grid.Column="5" Grid.Row="2" 
                                Height="30" Width="30" HorizontalAlignment="Right" Click="btnDeleteApp_Click" >
            <ParseControls:FwButton.Content>
                <Viewbox>
                    <Canvas Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0" Margin="-10">
                        <Path Width="31.6666" Height="31.6667" Canvas.Left="22.1666" Canvas.Top="22.1667" Stretch="Fill" 
                              Fill="#FFffffff" Data="F1 M 26.9166,22.1667L 37.9999,33.25L 49.0832,22.1668L 53.8332,26.9168L 42.7499,38L 53.8332,49.0834L 49.0833,53.8334L 37.9999,42.75L 26.9166,53.8334L 22.1666,49.0833L 33.25,38L 22.1667,26.9167L 26.9166,22.1667 Z "/>
                    </Canvas>
                </Viewbox>
            </ParseControls:FwButton.Content>
        </ParseControls:FwButton>

    </Grid>
</UserControl>
